package org.example.aienglishapp.mapper.article;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.example.aienglishapp.entity.article.Favorite;

import java.util.List;

@Mapper
public interface FavoriteMapper {

    void addFavorite(@Param("userId") Long userId, @Param("articleId") Long articleId);

    void removeFavorite(@Param("userId") Long userId, @Param("articleId") Long articleId);

    // 获取用户所有收藏
    List<Favorite> getAllFavoritesByUserId(@Param("userId") Long userId);

    // 根据 ID 获取收藏
    Favorite getFavoriteById(@Param("favoriteId") Long favoriteId);

    // 根据 userId 和 articleId 查询是否已收藏
    Favorite getFavoriteByUserIdAndArticleId(@Param("userId") Long userId, @Param("articleId") Long articleId);

}